﻿@using Entity.ProjectEnt;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
    List<CustomerAndThingsNameEntity> boxTypeObjList = ViewData["boxTypx"] as List<CustomerAndThingsNameEntity>;
}
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Project/CarriageBox/GetGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                { label: '箱号编号', name: 'CarriageBoxID', width: 150, align: 'center', cellattr: addCellAttr },
                { label: '到站所属车号', name: 'InitBelongCarriageId', width: 150, align: 'center', cellattr: addCellAttr },
                { label: '封号', name: 'FenHao', width: 200, align: 'center', cellattr: addCellAttr },
                { label: '箱主', name: 'BoxType', width: 50, align: 'center', cellattr: addCellAttr },
                { label: '蓬布号', name: 'Tarpaulin', width: 200, align: 'center', cellattr: addCellAttr },
                { label: '到站时间', name: 'InitBelongTime', width: 130, align: 'center', cellattr: addCellAttr },
                { label: '品名', name: 'ThingsName', width: 200, align: 'center', cellattr: addCellAttr },
                { label: '装车所属车号', name: 'ChangeBelongCarriageId', width: 200, align: 'center', cellattr: addCellAttr },
                { label: '装车时间', name: 'ChangeBelongTime', width: 130, align: 'center', cellattr: addCellAttr },
                { label: '离开时间', name: 'LeaveTime', width: 130, align: 'center', cellattr: addCellAttr },
                {
                    label: '备注说明', name: 'Remark', width: 200, align: 'center', cellattr: addCellAttr
                }
            ],
            pager: "#gridPager",
            sortname: 'InitBelongTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: {
                    keyword: $("#txt_keyword").val(),
                    StartTime: $("#sTime").val(),
                    EndTime: $("#eTime").val(),
                    Daozhan: $("#txt_keyworddaozhan").val(),
                    Zhuangche: $("#txt_keywordZhuangche").val(),
                    Xiangzhu: $("#txt_keywordXiangzhu").val()
                },
            }).trigger('reloadGrid');
        });

        $("#btn_export").click(function () {
            debugger;
            var keyValue = $("#txt_keyword").val();
            var StartTime = $("#sTime").val();
            var EndTime = $("#eTime").val();
            var Daozhan = $("#txt_keyworddaozhan").val();
            var Zhuangche = $("#txt_keywordZhuangche").val();
            var Xiangzhu = $("#txt_keywordXiangzhu").val();
            window.location.href = "/Project/CarriageBox/GetGridExportExcell?keyword=" + keyValue + "&StartTime=" + StartTime + "&EndTime=" + EndTime + "&Daozhan=" + Daozhan + "&Zhuangche=" + Zhuangche + "&Xiangzhu=" + Xiangzhu;
        })
    }
    function addCellAttr(rowId, val, rawObject, cm, rdata) {
        if (rawObject.Remark == "坏") {
            return "style='color:red'";
        } else {
            return "style='color:green'";
        }

    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Form",
            title: "修改箱号",
            url: "/Project/CarriageBox/Form?keyValue=" + keyValue,
            width: "600px",
            height: "450px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/Project/CarriageBox/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_editRemoveInfo() {
        $.deleteForm({
            url: "/Project/CarriageBox/RemoveBindInfo",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }

</script>

<style>
    #gbox_gridList {
        z-index: -1;
    }
</style>


<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        @*<div class="btn-group">
                <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新增车型</a>
            </div>*@
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改箱号信息</a></li>
                <li><a id="NF-edit" onclick="btn_editRemoveInfo()"><i class="fa fa-pencil-square-o"></i>消除装车绑定信息</a></li>
                <li><a id="NF-delete" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除此箱号</a></li>
                @*<li><a id="NF-Details" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看课程</a></li>*@
                <li class="split"></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td class="formValue">
                    <select class="btn-group" id="txt_keywordXiangzhu" style="padding: 6px; background-image: none; border: 1px solid ; border-radius: 4px;">
                        @if (boxTypeObjList.Count > 0)
                        {
                            <option value="">所有箱主类型</option>
                            foreach (var item in boxTypeObjList)
                            {
                                <option value="@item.Name">@item.Name</option>
                            }
                        }
                    </select>
                </td>
                <td>
                    <div class="input-group" style="padding-left:11px;padding-right:10px;">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="按照箱号模糊搜索" style="width: 150px;">
                        <input id="txt_keyworddaozhan" type="text" class="form-control" placeholder="按照到站车号查询" style="width: 150px;">
                        <input id="txt_keywordZhuangche" type="text" class="form-control" placeholder="按照装车车号查询" style="width: 150px;">
                        @*<span style="margin-left:50px;">按照添加车辆时间区间查询：</span>*@

                        <input id="sTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="到站开始查询时间" style="width: 200px; margin-right:20px;margin-left:50px;">
                        <input id="eTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="到站结束查询时间" style="width: 200px; margin-right:20px;">
                        <button id="btn_search" type="button" class="btn  btn-primary active"><i class="fa fa-search"></i></button>

                        <span class="input-group-btn">
                            <button id="btn_export" style="margin-left: 30px;padding-left: 7px;padding-right: 7px;" type="button" class="btn  btn-primary active">导出</button>
                        </span>

                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<style>
    table tr td {
        padding-left: 15px;
    }
</style>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
